<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"/>
    <title>爱贝儿医</title>

    <link rel="stylesheet" href="business/style/user/style/user.css?v=6">

    <script src="business/resource/js/jquery-1.11.1.min.js"></script>
    <script src="app/js/user/user_base.js"></script>
    <script src="app/js/common.js"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <style>
        .OKCon{background:#F5F8F6;width:74%;border:1px #E8E8E8 solid;border-radius: 12px;position:fixed;top:0;left:0;margin-left:10%;z-index: 100;text-align: center;color:#333;padding:20px 0 59px; font-family: 微软雅黑;
            font-size:0.75rem;padding-left:3%;padding-right:3%;overflow: hidden;min-height:80px;line-height:1.5;height: auto;}
        .OKCon .OKConBtn{font-size:100%;color:#3E8FDD;border-radius: 4px;width:100%;height:39px;line-height:39px;text-align: center;position:absolute;bottom:0px;left:0;background:url(business/style/bgbgbgbg.png) repeat-x bottom;border-top:1px solid #E8E8E8;}
        .opacityinput{height:100%;position:fixed;top:0px;left:0px;width:100%;z-index:100;background:#000;opacity: 0.6;}
    </style>
</head>
<script type="text/javascript">
    //医院显示
    function get_select(input_id,req_method){
        $(".searchUl li").remove();
        var content = $("#"+input_id).val();
        if(content){
            var data ={'name':content};
            var res = common.post('user',req_method,data);
            if(res.result == 0){
                for(var i=0;i<res.datas.length;i++){
                    $(".searchUl").append("<li>"+res.datas[i]+"</li>");
                }
            }
        }
    }

</script>


<body>
    <!-- 头部 -->
    <header>
        <a href="javascript:;"  <?php if($myself_res->data['userType'] == '医生'):?>class="active" <?php endif;?>>医生</a>
        <a href="javascript:;" <?php if($myself_res->data['userType'] == '护士'):?>class="active" <?php endif;?>>护士</a>
        <a href="javascript:;" <?php if($myself_res->data['userType'] == '医学生'):?>class="active" <?php endif;?>>医学师生</a>
    </header>
    <!-- 头部 -->
    <!-- 内容 -->
    <div id="content">
        <div class="list">
            <input type="hidden" id="用户id" name="用户id" value="<?=$user_id?>">
            <form action="<?=$use_post_url?>" method="post" id="form1">
                <input type="hidden" name="type" id="type1" value="医生"/>
                <input type="hidden" id ="id" name="医师详情id" value="<?=@$myself_res->data['id']?>">
                <input type="hidden" name="医师工作证" value="<?=$pic?>">
                    <div class="formItem avatar" onclick="uploadimg('11')">
                        <span class="title">编辑头像</span>
                        <div class="avatarImg" ><img src="<?=$avatar?>" class="preview11" alt=""></div>
                        <span class="describe">请拍摄上传您的真实照片</span>
                        <input type="file" >
                    </div>
                    <div class="form">

                        <input type="text" name="name" id="name1" value="<?=$myself_res->data['name']?>"><span>您的姓名</span></div>
                    <div class="form hospi" in="0"><input type="text"  name="医院"  id="hostpital1" value="<?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?>" ><span>所在医院</span><i><?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?></i></div>
                    <div class="form pro"><input type="text" name="专业领域" id="area1" value="<?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['专业领域']?><?php endif;?>"><span>所在科室</span><i><?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['专业领域']?><?php endif;?></i></div>
                    <div class="form worname"><input type="text" name="zhiwu" id="zhiwu1"
value="<?=$myself_res->data['职务']?>"><span>您的职称</span><i><?=$myself_res->data['职务']?></i></div>

                    <div class="photo">
                        <p>医护人员请您上传医师执业证/资格证/职称证/工作牌等（需包含真实姓名、医院等信息），医学师生请上传其他相关证件</p>
                        <div class="phbot">
                            <div class="phleft">
                                <div class="plimg" onclick="uploadimg1('12')"><img  class="preview12" src="<?=$pic?>" alt=""></div>
                                <p>点此上传图片</p>
                                <input type="file" >
                            </div>
                            <div class="phright">
                                <p>示例照片：</p>
                                <div><img src="business/style/user/style/exapmle1.png" alt=""><img src="business/style/user/style/exapmle2.png" alt=""></div>
                                <p>如您在会议现场，亦可上传本人在会场照片证明身份</p>
                            </div>
                        </div>
                    </div>
                    <div class="form"><input type="text" name="资格证号" value="<?=$myself_res->data['资格证号']?>"><span>医师资格证号</span></div>
                    <div class="form personal"><input type="text" name="remark" value="<?=$myself_res->data['简介']?>"><span>个人介绍(选填)</span></div>
                    <input type="button" id="sub1" onclick="bitian('1')" value="提交" class="sub">
            </form>
        </div>
        <div class="list">
            <form action="<?=$use_post_url?>" method="post" id="form2">
                <input type="hidden" name="type" id="type2" value="护士"/>
                <input type="hidden" name="医师详情id" value="<?=@$myself_res->data['id']?>">
                <input type="hidden" name="医师工作证" value="<?=$pic?>">
                    <div class="formItem avatar" onclick="uploadimg('22')">
                        <span class="title">编辑头像</span>
                        <div class="avatarImg"><img src="<?=$avatar?>" class="preview22" alt=""></div>
                        <span class="describe">请拍摄上传您的真实照片</span>
                        <input type="file" >
                    </div>

                    <div class="form"><input type="text" name="name" id="name2"
value="<?=$myself_res->data['name']?>"><span>您的姓名</span></div>
                    <div class="form hospi"  in="1"><input type="text" name="医院" id="hostpital2"  value="<?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?>" ><span>所在医院</span><i><?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?></i></div>
                    <div class="form pro"><input type="text" name="专业领域" id="area2"
value="<?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['专业领域']?><?php endif;?>" ><span>所在科室</span><i><?php if(!empty($myself_res->data['职务'])):?><?=$myself_res->data['专业领域']?><?php endif;?></i></div>
                    <div class="form worname"><input type="text" name="zhiwu" id="zhiwu2" value="<?=$myself_res->data['职务']?>" ><span>您的职称</span><i><?=$myself_res->data['职务']?></i></div>


                    <div class="photo">
                        <p>医护人员请您上传医师执业证/资格证/职称证/工作牌等（需包含真实姓名、医院等信息），医学师生请上传其他相关证件</p>
                        <div class="phbot">
                            <div class="phleft">
                                <div class="plimg" onclick="uploadimg1('22')"><img  class="preview22" src="<?=$pic?>" alt=""></div>
                                <p>点此上传图片</p>
                                <input type="file" >
                            </div>
                            <div class="phright">
                                <p>示例照片：</p>
                                <div><img src="business/style/user/style/exapmle1.png" alt=""><img src="business/style/user/style/exapmle2.png" alt=""></div>
                                <p>如您在会议现场，亦可上传本人在会场照片证明身份</p>
                            </div>
                        </div>
                    </div>
                    <div class="form"><input type="text"   name="资格证号" value="<?=$myself_res->data['资格证号']?>"><span>医师资格证号</span></div>
                    <div class="form personal"><input type="text" name="remark" value="<?=$myself_res->data['简介']?>"><span>个人介绍(选填)</span></div>
                    <input type="button" value="提交" class="sub" onclick="bitian('2')">
            </form>
        </div>
        <div class="list">
            <form action="<?=$use_post_url?>" method="post" id="form3" >
                <input type="hidden" name="type" id="type3" value="医学生"/>
                <input type="hidden" name="医师详情id" value="<?=@$myself_res->data['id']?>">
                <input type="hidden" name="医师工作证" value="<?=$pic?>">
                    <div class="formItem avatar" onclick="uploadimg('31')">
                        <span class="title">编辑头像</span>
                        <div class="avatarImg"><img src="<?=$avatar?>" class="preview31" alt=""></div>
                        <span class="describe">请拍摄上传您的真实照片</span>
                        <input type="file" >
                    </div>
                    <div class="form"><input type="text" name="name" id="name3" value="<?=$myself_res->data['name']?>"><span>您的姓名</span></div>
                    <div class="form hospi"  in="2"><input type="text" name="医院" id="hostpital3"  value="<?php if(empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?>" ><span>所在学校</span><i><?php if(empty($myself_res->data['职务'])):?><?=$myself_res->data['医院']?><?php endif;?></i></div>
                    <div class="form"><input type="text" name="专业领域" id="area3" value="<?php if(empty($myself_res->data['职务'])):?><?=$myself_res->data['专业领域']?><?php endif;?>"><span>所学专业</span></div>
                    <div class="photo">
                        <p>医护人员请您上传医师执业证/资格证/职称证/工作牌等（需包含真实姓名、医院等信息），医学师生请上传其他相关证件</p>
                        <div class="phbot">
                            <div class="phleft">
                                <div class="plimg" onclick="uploadimg1('32')"><img  class="preview32" src="<?=$pic?>" alt=""></div>
                                <p>点此上传图片</p>
                                <input type="file" >
                            </div>
                            <div class="phright">
                                <p>示例照片：</p>
                                <div><img src="business/style/user/style/exapmle1.png" alt=""><img src="business/style/user/style/exapmle2.png" alt=""></div>
                                <p>如您在会议现场，亦可上传本人在会场照片证明身份</p>
                            </div>
                        </div>
                    </div>
                    <div class="form personal"><input type="text" name="remark" value="<?=$myself_res->data['简介']?>"><span>个人介绍(选填)</span></div>
                    <input type="button" value="提交" class="sub" onclick="bitian('3')">
            </form>
        </div>
        <!-- 选择医院弹出层 -->
        <div class="layerHospital layer">
            <div class="layerHead">
                <div class="tcClose"><img src="business/style/user/style/tcClose.png" alt=""></div>
                <div class="layerSubBtn"><input type="submit" value="确定" ></div>
            </div>
            <div class="layerHospitalBody">
                <div class="hosSearch">

                    <!--   <input type="text" id="userHospital"  onkeyup="get_select('userHospital', 'getHospitals')">-->

                       <input type="text" id="" >
                  </div>
                  <ul class="searchUl">

                  </ul>
              </div>
          </div>
          <!--选择医院弹出层 -->
        <!-- 选择职称弹出层 -->
        <div class="layerProfessional layer">
            <div class="layerHead">
                <div class="tcClose"><img src="business/style/user/style/tcClose.png" alt=""></div>
                <div class="layerSubBtn"><input type="submit" value="确定"></div>
            </div>
            <div class="layerProfessionalBody">
                <ul class="ProfessionalUl">
                </ul>
            </div>
        </div>       
        <!-- 选择职称弹出层 -->  
        <!-- 选择科室弹出层 -->
        <div class="layerAdministrative layer">
            <div class="layerHead">
                <div class="tcClose"><img src="business/style/user/style/tcClose.png" alt=""></div>
                <div class="layerSubBtn"><input type="submit" value="确定" ></div>
            </div>
            <div class="layerAdministrativeBody">
                <div class="AdministrativeBtns">
                    <?php foreach ($keshi as $k): ?>
                    <div class="AdministrativeBtn"><?=$k['name']?></div>
                    <?php endforeach; ?>

                </div>
                <ul class="AdministrativeUl">

                </ul>
            </div>
        </div>       
        <!-- 选择科室弹出层 -->       
    </div>
    <!-- 内容 -->
    <!-- 弹出层背景 -->
    <div class="layerBg"></div>
    <!-- 弹出层背景 -->
    <!-- 尾部 -->
    <?php require 'app/templates/common/download.html'; ?>
    <!-- 尾部 -->
</body>
<script type="text/javascript">
    //必填字段
    function bitian(num){
        var type = $("#type"+num).val();
        var zhiwu =  $("#zhiwu"+num).val();
        var name =  $("#name"+num).val();
        var hostpital = $("#hostpital"+num).val();
        var area = $("#area"+num).val();
        if( name.length==0){
            common.showMsgBox1('请输入您的姓名');
            return false;
        }
        if( hostpital.length==0){
            var tishi='';
            if(num==3){
                tishi='请选择您的所在学校';
            }else{
                tishi='请选择您的所在医院';
            }
            common.showMsgBox1(tishi);
            return false;
        }

        if( area.length==0){
            var tishi1='';
            if(num==3){
                tishi1='请输入您的所学专业';
            }else{
                tishi1='请选择您的所在科室';
            }
            common.showMsgBox1(tishi1);
            return false;
        }
        if(type!='医学生'){
            if(zhiwu.length==0){
                common.showMsgBox1('请选择您的职称');
                return false;
            }
        }
       $("#form"+num).submit();

    }



    var images = {
        localId: [],
        serverId: []
    };

    wx.config({
        debug: false,
        appId: '<?=$this->signPackage["appId"];?>',
        timestamp: '<?=$this->signPackage["timestamp"];?>',
        nonceStr: '<?=$this->signPackage["nonceStr"];?>',
        signature: '<?=$this->signPackage["signature"];?>',
        jsApiList: [
            'startRecord',
            'stopRecord',
            'onRecordEnd',
            'playVoice',
            'pauseVoice',
            'stopVoice',
            'uploadVoice',
            'downloadVoice',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'onMenuShareAppMessage',
            'onMenuShareTimeline',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'onMenuShareQZone'
        ]
    });

    title = '爱贝儿医';
    desc = '爱贝儿医—专注于做儿科医生间学习工作交流平台。平台拥有数十位来自省级以上重点三甲医院的儿科专家、重点医院儿科学科带头人、国内儿科权威人士组成的豪华专家团队。';
    links = '';
    imgUrl = '<?= G_SITE_BASE ?>/business/img/logoRed2.png';
    weixinShare(title, desc, links, imgUrl);

    function uploadimg(num){

        wx.chooseImage({
            count: 1, // 默认9
            sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
            success: function (res) {
                localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                syncUpload(localIds,num);
            }
        });
    }
    

    var syncUpload = function(localIds,num){
        var localId = localIds.pop();
        wx.uploadImage({
            localId: localId,
            isShowProgressTips: 1,
            success: function (res) {

                var imageId = res.serverId; // 返回图片的服务器端ID
                var userid = $('#用户id').val(); //get user id

                $.post('<?=$up_user_img?>',{'imageId':imageId,"userid":userid,'table':'user_table'},function(data){
                    $(".preview"+num).attr("src",data);
                })
            }
        });
    };

    function uploadimg1(num1){
        wx.chooseImage({
            count: 1, // 默认9
            sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
            success: function (res) {
                localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                syncUpload1(localIds,num1);
                $(document)[0].body.scrollTop = $(document)[0].body.scrollHeight;
            }
        });
    }
    // 图片显示限制函数
    function photoshow(){
        var  scale = $('.plimg>img').width()/$('.plimg>img').height();
        if(scale > 1.27){
            $('.plimg>img').css('width','100%');
        } else{
            $('.plimg>img').css('height',$('.plimg').height());
        }
    }



    var syncUpload1 = function(localIds,num1){
        var localId = localIds.pop();
        wx.uploadImage({
            localId: localId,
            isShowProgressTips: 1,
            success: function (res) {

                var imageId = res.serverId; // 返回图片的服务器端ID

                var userid = $('#用户id').val(); //get user id
                var id = $("input[name='医师详情id']").val();

                $.post('<?=$up_user_img?>',{'id':id,'imageId':imageId,"userid":userid,'table':'doctor'},function(data){

                    $(".preview"+num1).attr("src",data);
                    photoshow();
                })

            }
        });
    };
</script>
</html>